home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr11
/
pdox693.zip
/
TI131.ASC
< prev
next >
Wrap
Text File
|
1992-09-14
|
9KB
|
265 lines
PRODUCT : Paradox NUMBER : 131
VERSION : All
OS : DOS
DATE : September 14, 1992 PAGE : 1/4
TITLE : Preventing Users From Accidentally Deleting Records
Intended Audience:
A moderate level of Paradox knowledge.
Prerequisites:
Previous experience in writing PAL code is helpful.
Purpose:
This Technical Information sheet illustrates how you can use a
PAL script to prevent users from accidentally deleting records.
Paradox allows users to easily delete records from a table. Some
users, though, may prefer to have Paradox verify that a specific
record should be deleted. This can be quickly accomplished with
a small PAL script and an adjustment to the way Paradox handles
the <Delete> key.
While this verification process is easy to add, it can seem
difficult to those with a limited exposure to Paradox. Before
attempting the techniques discussed here, please make sure you
are familiar with the following concepts:
- PAL scripts. Users should know what a PAL script is and
how to write and edit one. See the first few chapters of
the PAL Reference Guide for information about creating and
using scripts (for versions earlier than 4.0, see the PAL
User's Guide). It would also be useful to know how PAL
works with variables, though this is not required.
- Network users should also be familiar with Paradox's use
of private directories and the INIT script. Private
directories are covered in the Network Installation Guide
(for versions earlier than 4.0, see the Network
Administrator's Guide) and the INIT script is discussed in
Chapter 7 of the PAL Programmer's Guide (for versions
earlier than 4.0, see the PAL User's Guide).
Once the verification process is set up, it is simple to use.
The only person who needs a basic understanding of the above
concepts is the one implementing it.
Installing the process requires two steps. First, you will need
a PAL script that makes certain the record should be deleted by
allowing the user to verify the deletion or cancel the operation.
PRODUCT : Paradox NUMBER : 131
VERSION : All
OS : DOS
DATE : September 14, 1992 PAGE : 2/4
TITLE : Preventing Users From Accidentally Deleting Records
The following script shows one example of how this can be
accomplished.
CMode = Sysmode()
If (not (IsFieldView())) and (CMode = "Edit" or
CMode = "CoEdit" or CMode = "DataEntry") Then
Showmenu
"Cancel" : "Oops, do NOT remove this record.",
"Ok" : "Yes, PERMANENTLY delete this record."
Default "Cancel" to DelRec
If (Retval) and (DelRec = "Ok") Then
Del
Endif
Else
Del
Endif
Release Vars CMode, DelRec
To actually delete a record with this script while Paradox is in
an appropriate mode, the user must press <Delete> and then select
Ok from the menu that appears. If the user presses <Delete>
accidentally, selecting Cancel or pressing <Esc> returns the
user to the table without deleting the current record.
To create this script, use the following process:
- First, load Paradox and change to the directory where
Paradox is installed with the Tools | More | Directory
command. The default directory for Paradox 4.0 is
C:\PDOX40.
- Next, select Scripts | Editor | New (for versions earlier
than 4.0, select Write instead of New). When the "Name:"
prompt appears, type DELREC and press <Enter>.
- When the Script Editor screen appears, type in the script
exactly as it appears above.
- After you have typed the script into the Script Editor,
press <F2>. Your DELREC script will be saved.
PRODUCT : Paradox NUMBER : 131
VERSION : All
OS : DOS
DATE : September 14, 1992 PAGE : 3/4
TITLE : Preventing Users From Accidentally Deleting Records
The second part of this process actually "adds" the feature to
Paradox and can take one of two forms. Perhaps the quickest way
to do this is to press <Alt-F10>, select Miniscript, type:
SETKEY -83 PLAY "C:\\PDOX40\\DELREC"
and then press <Enter>. This tells Paradox to play the DELREC
script every time the <Delete> key is pressed.
If your copy of Paradox is located in a different directory, be
sure to change the C:\\PDOX40\\ part of the SETKEY command to
reflect the actual directory where Paradox is installed. (Make
certain you use two "back-slashes" (\\) to separate the various
branches of the directory name.)
The Miniscript approach is a good way to test your new script,
for it immediately changes the behavior of the <Delete> key.
There is a drawback, though. The new definition only stays in
effect until you exit Paradox.
To have this feature "permanently" added to your installed copy
of Paradox, include the above line to your INIT script located in
the directory where Paradox is installed. The INIT script is
analogous to the DOS AUTOEXEC.BAT file; that is, Paradox
automatically looks for (and executes) the INIT script every time
the program starts. Network users will need to have an INIT
script located in their private directories; that is, the
directory where their personalized PARADOX.CFG file is located.
To change an existing INIT script, select Scripts | Editor | Open
(for versions earlier than 4.0, select Edit instead of Open) from
the main Paradox menu. If you get an error message similar to
"Cannot find INIT script", you may not have an INIT script and
you should use Scripts | Editor | New to create one (for versions
earlier than 4.0, use Write instead of New). Be sure to change
to the proper directory before creating the INIT script.
There are other ways to design the DELREC script. The one given
earlier is not the only way to approach the process, although it
does follow good programming rules. It makes certain the user is
in a mode where records can be deleted, allows the user to press
the <Esc> key during the menu and "cleans up after itself" by
PRODUCT : Paradox NUMBER : 131
VERSION : All
OS : DOS
DATE : September 14, 1992 PAGE : 4/4
TITLE : Preventing Users From Accidentally Deleting Records
clearing the variables it defines. An alternate approach for
DELREC might be:
@ 0,0
?? "Delete this record? (Y/N): "
Accept "A1" Picture "{Y,N}" Default "N" Required To DelRec
If DelRec = "Y" Then
Del
Endif
This example is not as detailed as the earlier one, but it can be
just as effective. It also does less error checking, potentially
making life more difficult for the average user. Still, with a
little work, it could be as useful as the first example script.
If this second approach is used for DELREC, the user will have to
press the <Delete> key, hit <Backspace> to delete the default "N"
value which appears in the upper left corner of the screen, type
Y and finally press <Enter> before the record will be erased.
As you can see, PAL allows you to approach a specific problem
from different directions. The PAL Reference Guide describes the
syntax and use of each command and function used in the two
example scripts (for versions earlier than 4.0 see the PAL User's
Guide). It is a good resource for any questions you might have
along these lines. Feel free to experiment with different
variations of these examples (or to create your own approach).
Make certain, though, to make backups of any data files you
experiment with.
DISCLAIMER: You have the right to use this technical information
subject to the terms of the No-Nonsense License Statement that
you received with the Borland product to which this information
pertains.